package com.tojabo.swing.fourteen_table;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class JTableDemo2 {
	public JTableDemo2() {
		JFrame f = new JFrame();
		JTable table = new JTable(10, 10);// 创建一个十行和十列的空表格
		table.setPreferredScrollableViewportSize(new Dimension(550, 30));
		JScrollPane scrollPane = new JScrollPane(table);
		f.getContentPane().add(scrollPane, BorderLayout.CENTER);
		f.setTitle("表格测试窗口");
		f.pack();
		f.setVisible(true);
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}

	public static void main(String[] args) {
		JTableDemo2 b = new JTableDemo2();
	}
}
